home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emstools.arc / EMMLIB.ARC / EMM24_A.ASM < prev    next >
Assembly Source File  |  1990-02-04  |  16KB  |  233 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM24_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;     FUNCTION NAME:   move_memory_region                                     ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function copies a region of memory in the          ;
  7. ;                     following memory source/destination combinations.       ;
  8. ;                                                                             ;
  9. ;                        1. conventional memory to conventional memory        ;
  10. ;                        2. conventional memory to expanded memory            ;
  11. ;                        3. expanded memory to conventional memory            ;
  12. ;                        4. expanded memory to expanded memory                ;
  13. ;                                                                             ;
  14. ;                     You do not have to save and restore the expanded memory ;
  15. ;                     mapping context to perform these move operations.  The  ;
  16. ;                     current mapping context is maintained throughout this   ;
  17. ;                     operation.                                              ;
  18. ;                                                                             ;
  19. ;                     The length of the region is limited by the amount of    ;
  20. ;                     expanded memory allocated to the handles specified.     ;
  21. ;                     However, in most practical applications, the region     ;
  22. ;                     length will be considerably smaller.  A region length   ;
  23. ;                     of zero is not an error, and no move will be performed. ;
  24. ;                                                                             ;
  25. ;                     A region length which exceeds 16K bytes is not an       ;
  26. ;                     error.  In this case the function assumes that a group  ;
  27. ;                     of logical pages is the target for the move.  The       ;
  28. ;                     logical page specified represents the first logical     ;
  29. ;                     page in which the move will take place.  If the region  ;
  30. ;                     length exceeds 16K bytes, or if the region is less than ;
  31. ;                     16K bytes but spans logical pages, there must be        ;
  32. ;                     sufficient logical pages remaining after the first      ;
  33. ;                     logical page for the entire region to fit.              ;
  34. ;                                                                             ;
  35. ;                     If your application needs to save a region of           ;
  36. ;                     conventional memory in expanded memory, you can move it ;
  37. ;                     without having to perform a save or restore of the      ;
  38. ;                     current mapping context.  The memory manager maintains  ;
  39. ;                     the context.  A move of up to 1M byte may be performed, ;
  40. ;                     although practical lengths are substantially less than  ;
  41. ;                     this value.                                             ;
  42. ;                                                                             ;
  43. ;                     If the source and destination handles are identical,    ;
  44. ;                     the source and destination regions are tested for       ;
  45. ;                     overlap before the move.  If they overlap, the move     ;
  46. ;                     direction is chosen so that the destination region      ;
  47. ;                     receives an intact copy of the source region.  A status ;
  48. ;                     will be returned indicating that this overlap has       ;
  49. ;                     occurred.                                               ;
  50. ;                                                                             ;
  51. ;           PASSED:   &ms:                                                    ;
  52. ;                        is a far pointer to a structure which contains       ;
  53. ;                        the source and destination information for the move. ;
  54. ;                        The structure members are described here:            ;
  55. ;                                                                             ;
  56. ;                        ms.region_size:                                      ;
  57. ;                           is the length of the memory region (in bytes) to  ;
  58. ;                           be moved.                                         ;
  59. ;                                                                             ;
  60. ;                        ms.source_mem_type:                                  ;
  61. ;                           is the type of memory where the source region     ;
  62. ;                           resides.  A value of zero indicates that the      ;
  63. ;                           source region resides in conventional memory      ;
  64. ;                           (excluding the page frame segment).  A value of   ;
  65. ;                           one indicates that the source region resides in   ;
  66. ;                           expanded memory.                                  ;
  67. ;                                                                             ;
  68. ;                        ms.source_handle:                                    ;
  69. ;                           if the source region resides in expanded memory,  ;
  70. ;                           it specifies the handle number associated with    ;
  71. ;                           the source memory region.  If the source region   ;
  72. ;                           resides in conventional memory, it has no meaning ;
  73. ;                           and should be set to zero for future              ;
  74. ;                           compatibility.                                    ;
  75. ;                                                                             ;
  76. ;                        ms.source_init_offset:                               ;
  77. ;                           is the offset within the source region at which   ;
  78. ;                           to begin the move.                                ;
  79. ;                                                                             ;
  80. ;                           If the source region resides in expanded memory,  ;
  81. ;                           it specifies an offset relative to the beginning  ;
  82. ;                           of the 16K-byte source page.  Because the offset  ;
  83. ;                           is relative to the beginning of a 16K-byte source ;
  84. ;                           expanded memory page, it may only take on values  ;
  85. ;                           between 0000h and 3FFFh.                          ;
  86. ;                                                                             ;
  87. ;                           If the source region resides in conventional      ;
  88. ;                           memory, it specifies the offset, relative to the  ;
  89. ;                           beginning of the source segment, at which to      ;
  90. ;                           begin the move.  Because the offset is relative   ;
  91. ;                           to the beginning of a 64K-byte conventional       ;
  92. ;                           memory segment, it may take on values between     ;
  93. ;                           0000h and FFFFh.                                  ;
  94. ;                                                                             ;
  95. ;                        ms.source_init_log_page_or_seg:                      ;
  96. ;                           is the initial segment or logical page number     ;
  97. ;                           within the source region at which to begin the    ;
  98. ;                           move.                                             ;
  99. ;                                                                             ;
  100. ;                           If the source region resides in expanded memory,  ;
  101. ;                           it specifies the logical page within the source   ;
  102. ;                           region at which to begin the move.                ;
  103. ;                                                                             ;
  104. ;                           If the source region resides in conventional      ;
  105. ;                           memory, it specifies the initial segment address  ;
  106. ;                           within conventional memory at which to begin      ;
  107. ;                           the move.                                         ;
  108. ;                                                                             ;
  109. ;                        ms.dest_mem_type:                                    ;
  110. ;                           is the type of memory where the destination       ;
  111. ;                           region resides.  A value of zero indicates        ;
  112. ;                           conventional memory.  A value of one indicates    ;
  113. ;                           expanded memory.                                  ;
  114. ;                                                                             ;
  115. ;                        ms.dest_handle:                                      ;
  116. ;                           if the destination region resides in expanded     ;
  117. ;                           memory, it specifies the handle number associated ;
  118. ;                           with the destination memory region.               ;
  119. ;                                                                             ;
  120. ;                           If the destination region resides in conventional ;
  121. ;                           memory, it has no meaning and should be set to    ;
  122. ;                           zero for future compatibility.                    ;
  123. ;                                                                             ;
  124. ;                        ms.dest_init_offset:                                 ;
  125. ;                           is the offset within the destination region at    ;
  126. ;                           which to begin the move.                          ;
  127. ;                                                                             ;
  128. ;                           If the destination region resides in expanded     ;
  129. ;                           memory, it specifies an offset relative to the    ;
  130. ;                           beginning of the 16K-byte destination page.       ;
  131. ;                           Because the offset is relative to the beginning   ;
  132. ;                           of a 16K-byte source expanded memory page, it may ;
  133. ;                           only take on values between 0000h and 3FFFh.      ;
  134. ;                                                                             ;
  135. ;                           If the destination region resides in conventional ;
  136. ;                           memory, it specifies the offset, relative to the  ;
  137. ;                           beginning of the destination segment, to begin    ;
  138. ;                           the move.  Because the offset is relative to the  ;
  139. ;                           beginning of a 64K conventional memory segment,   ;
  140. ;                           it may take on values between 0000h and FFFFh.    ;
  141. ;                                                                             ;
  142. ;                        ms.dest_init_log_page_or_seg:                        ;
  143. ;                           is the initial segment or logical page number     ;
  144. ;                           within the destination region at which to begin   ;
  145. ;                           the move.                                         ;
  146. ;                                                                             ;
  147. ;                           If the destination region resides in expanded     ;
  148. ;                           memory then the value specifies the logical page  ;
  149. ;                           within the destination region at which to begin   ;
  150. ;                           the move.                                         ;
  151. ;                                                                             ;
  152. ;                           If the destination region resides in conventional ;
  153. ;                           memory, it specifies the initial segment address  ;
  154. ;                           within conventional memory at which to begin      ;
  155. ;                           the move.                                         ;
  156. ;                                                                             ;
  157. ;         RETURNED:   status:                                                 ;
  158. ;                        is the status EMM returns from the call.  All other  ;
  159. ;                        returned results are valid only if the status        ;
  160. ;                        returned is zero.  Otherwise they are undefined.     ;
  161. ;                                                                             ;
  162. ;                     The SOURCE memory region described by:                  ;
  163. ;                           ms.source_handle                                  ;
  164. ;                           ms.source_init_offset                             ;
  165. ;                           ms.source_init_log_page_or_seg                    ;
  166. ;                       is MOVED into the DESTINATION memory region:          ;
  167. ;                           ms.dest_handle                                    ;
  168. ;                           ms.dest_init_offset                               ;
  169. ;                           ms.dest_init_log_page_or_seg                      ;
  170. ;                                                                             ;
  171. ; C USE CONVENTION:   unsigned int     status;                                ;
  172. ;                     MOVE_XCHG_STRUCT ms;                                    ;
  173. ;                                                                             ;
  174. ;                     ms.region_size                 = 640 * 1024;            ;
  175. ;                     ms.source_mem_type             = CONV_MEM;              ;
  176. ;                     ms.source_handle               = 0;                     ;
  177. ;                     ms.source_init_log_page_or_seg = 0x0000;                ;
  178. ;                     ms.source_init_offset          = 0x0000;                ;
  179. ;                     ms.dest_mem_type               = EXP_MEM;               ;
  180. ;                     ms.dest_handle                 = 1;                     ;
  181. ;                     ms.dest_init_log_page_or_seg   = 0;                     ;
  182. ;                     ms.dest_init_offset            = 0x0000;                ;
  183. ;                                                                             ;
  184. ;                     status = move_memory_region (&ms);                      ;
  185. ;-----------------------------------------------------------------------------;
  186. .XLIST
  187. PAGE    60,132
  188.  
  189. IFDEF SMALL
  190.    .MODEL SMALL, C
  191. ENDIF
  192. IFDEF MEDIUM
  193.    .MODEL MEDIUM, C
  194. ENDIF
  195. IFDEF LARGE
  196.    .MODEL LARGE, C
  197. ENDIF
  198. IFDEF COMPACT
  199.    .MODEL COMPACT, C
  200. ENDIF
  201. IFDEF HUGE
  202.    .MODEL HUGE, C
  203. ENDIF
  204.  
  205. INCLUDE emmlib.equ
  206. INCLUDE emmlib.str
  207. INCLUDE emmlib.mac
  208. .LIST
  209. .CODE
  210.  
  211. move_memory_region    PROC                                                  \
  212.             USES DS SI,                                           \
  213.             ptr_move_struct:FAR PTR BYTE
  214.  
  215.     ;---------------------------------------------------------------------;
  216.     ;   do;                                                               ;
  217.     ;   .   move the contents of a source memory region to a destination  ;
  218.     ;   .   memory region;                                                ;
  219.     ;---------------------------------------------------------------------;
  220.     MOVE        AX, move_memory_fcn 
  221.     MOVE        DS:SI, ptr_move_struct
  222.     INT         EMM_int
  223.  
  224.     ;---------------------------------------------------------------------;
  225.     ;   .   return (EMM status);                                          ;
  226.     ;   end;                                                              ;
  227.     ;---------------------------------------------------------------------;
  228.     RET_EMM_STAT    AH
  229.  
  230. move_memory_region    ENDP
  231.  
  232. END
  233.